<?php

header('Access-Control-Allow-Origin: *');
include('../_inc/config.inc.php');

$data = array();
$data['error_code'] = 0;
$data['error_desc'] = '';
$data['result'] = array();

// Exécution de la requête
$query = 'SELECT * from categories';
			//echo $query;
$result = mysql_query($query);


// Vérification du résultat
if (!$result) {
    $data['error_code'] = 1;
	$data['error_desc'] = 'Erreur sur la requête';
	echo json_encode($data);
	exit();
}

// Utilisation du résultat
while ($row = mysql_fetch_assoc($result)) {
    $data['result'][] = $row;
}

echo json_encode($data);
/*
if (isset($_GET['callback'])) echo $_GET['callback'].'('.$data.');'; 
else echo $data;*/ 